package nc.ui.arap.global;


import nc.bs.pf.pub.PfDataCache;
import nc.bs.pub.pf.PfUtilTools;
import nc.bs.trade.billsource.BillTypeSetDataFinder;
import nc.bs.trade.billsource.DefaultBillFinder;
import nc.bs.trade.billsource.IBillDataFinder;
import nc.bs.trade.billsource.NullDataFinder;
import nc.vo.pub.billtype.BilltypeVO;

public class FITypeSetBillFinder extends DefaultBillFinder {

	@Override
	public IBillDataFinder createBillDataFinder(String billType) throws Exception {
		BilltypeVO type = PfDataCache.getBillType(billType);
		if(type == null)
			return  new NullDataFinder();
		IBillDataFinder finder = null;
		
		String datafinderclassname = type.getDatafinderclz();
		
		if(null==datafinderclassname&&type.getParentbilltype()!=null) 
			datafinderclassname=PfDataCache.getBillType(type.getParentbilltype()).getDatafinderclz();
		
		
		if(datafinderclassname != null) {
			finder = (IBillDataFinder) PfUtilTools.instantizeObject(billType, datafinderclassname);
		}else if(type.getForwardbilltype() != null)
			finder = new BillTypeSetDataFinder();
		else
			finder = super.createBillDataFinder(billType);

		return finder;
	}
}
